const app = getApp()
Page({
  data: {
    isActive: null,
    listMain: [

    ],
    storeyList: [],
    fixedTitle: null,
    toView: 'inTo0',
    oHeight: [],
    scroolHeight: 0,
    fixedTop: 0,
    cityId: '',
    inputValue: '',
    type: ''
  },
  onLoad: function (options) {
    if (JSON.stringify(options) != '{}') {
      this.setData({
        cityId: options.id,
        type: options.type
      })
      this.getSchoolList(Number(this.data.cityId))
    }

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  },
  //点击右侧字母导航定位触发
  getSchoolList(id) {
    app.Http.http({
      url: app.Api.SchoolList + '?id=' + id,
      method: 'POST',
      params: {}
    }).then(data => {
      this.setData({ listMain: data });
    }).catch(err => {
      console.log(err)
    })
  },
  searchSchoolList(val) {
    app.Http.http({
      url: app.Api.QueryLikeName + '?schoolName=' + val,
      method: 'GET',
      params: {}
    }).then(data => {
      this.setData({ listMain: data });
    }).catch(err => {
      console.log(err)
    })
  },
  toStorey(e) {
    let schoolId = e.currentTarget.dataset.schoolid ? e.currentTarget.dataset.schoolid : '';
    let schoolName = e.currentTarget.dataset.schoolname ? e.currentTarget.dataset.schoolname : ''
    app.WxService.navigateTo('/pages/storey/index', { type: this.data.type, schoolId: schoolId, schoolName: decodeURIComponent(schoolName) })

  },

  bindKeyInput: function (e) {
    this.setData({
      inputValue: e.detail.value
    })
    this.searchSchoolList(this.data.inputValue)
  },
  clearInput() {
    this.setData({
      inputValue: ''
    })
  }
})

